import { ICursorPagination } from './pagination'
import { IQueryParams } from './queryParams'
import { IOption } from './common'

export class RiskControlScheme {
  insCode: string | Institution
  category: string
  schemeCode: string
  schemeName: string
  remark: string
  schemeDesc: string
  platform: string
  rules: RiskControlRule[]
  createdAt: string
  updatedAt: string
  status: 'normal' | 'freeze'

  constructor(code?: string, name?: string) {
    this.schemeCode = code
    this.schemeName = name
  }
}

export interface Institution {
  code: string
  name: string
  num: string
  level: string
  nameEN: string
}

export interface IRiskControlSchemeQuery {
  limit: number
  keyword?: string
  size?: number
  page: number
  before?: string
  after?: string
  category?: string
  insCode?: string
}

export interface IRiskControlQueryParams extends IQueryParams {
  schemeCode?: string
  schemeName?: string
  submittedAtFrom?: string
  submittedAtTo?: string
}

export class RiskControlRule {
  createdTime?: string
  updatedTime?: string
  schemeCode?: string
  type: string
  name: string
  mode: string
  scene: string
  quota: number
  quotaStatic?: number
  level: string
  currency: string
  card_brand: string
  id?: number
  idStatic?: number
}

export interface IRiskControlBiz {
  biz: string
  bizId: string
  name: string
  nameEn: string
}

export enum RiskRuleModeEnum {
  Trade = '00',
  Day = '01',
  Month = '30',
  Refund = 'refund',
}

export const RiskRuleModeMap = {
  '00': 'RISK_CTRL_RULE_MODE.SINGLE',
  '01': 'RISK_CTRL_RULE_MODE.SINGLE_DAY',
  30: 'RISK_CTRL_RULE_MODE.SINGLE_MONTH',
  refund: 'RISK_CTRL_RULE_MODE.REFUND',
}

/** 退款维度 */
export const LevelOptions: IOption[] = [
  { label: '商户', value: 'merchant' },
  { label: '门店', value: 'store' },
]
